package com.dao.imp;

import com.entity.Address;
import com.entity.ShoppingCart;
import com.util.DBConn;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Mathison
 * @Title: FindCartInfo
 * @Package: com.dao.imp
 * @Description: TODO
 * @date 2021/11/28 19:03
 **/
public class FindCartInfo {
    public static ShoppingCart getCartInfo(String sql){
        ShoppingCart shoppingCart = new ShoppingCart();
        try{
            DBConn.init();
            ResultSet resultSet = DBConn.selectSql(sql);
            while (resultSet.next()){
                shoppingCart.setGood_amount(resultSet.getInt("good_amount"));
                shoppingCart.setGood_id(resultSet.getInt("good_id"));
                shoppingCart.setUser_id(resultSet.getInt("user_id"));
                shoppingCart.setChecked(resultSet.getBoolean("isChecked"));
            }
//            DBConn.closeConn();
        }catch (SQLException e){
            e.printStackTrace();
        }
        return shoppingCart;
    }
}
